home *** CD-ROM | disk | FTP | other *** search
/ Internet Info 1994 March / Internet Info CD-ROM (Walnut Creek) (March 1994).iso / networking / mail / mh / contrib / 9209 / sendproc < prev    next >
Text File  |  1992-09-20  |  6KB  |  208 lines

  1. #!/bin/ksh
  2. ###############################################################################
  3. # sendproc - a front end to the MH send command
  4. #
  5. # Gregory F. March (march@nynexst.com)
  6. #
  7. #------------------------------------------------------------------------------
  8. #
  9. # sendproc provides the following additions to the MH send command:
  10. #
  11. #    Addition of an X-Face: mail header
  12. #    Addition of an Fcc: mail header
  13. #    Addition of a .signature
  14. #
  15. # All of the above can be turned off. The default is on with the filespecs
  16. # set below. The files used can be changed via the command line as well.
  17. #
  18. # Search for the line containing "CONFIGURE" to see what you can change.
  19. #
  20. # NOTE: I guarantee nothing.
  21. #
  22. ###############################################################################
  23.  
  24. # CONFIGURE: Location of the MH send program
  25. SEND=/home/bonehead/local/bin/send
  26.  
  27. # CONFIGURE: Location of the internal .sig file
  28. INTERNAL=$HOME/.signature.internal
  29.  
  30. # CONFIGURE: Location of the external .sig file
  31. INTERNAL=$HOME/.signature.external
  32.  
  33. # CONFIGURE: You may want to change these...
  34.  
  35. XFACE=1            # Yes, we have a face file
  36. XFACEFN=$HOME/.face    # and this is where it is.
  37.  
  38. SIG=1            # Yes, send a signature
  39.  
  40. FCC=1            # Yes, we want to save outbound mail
  41. FCCFN=outbox        # and this is where we will save it
  42.  
  43. TMPFILE=/tmp/mh-send.$$    # Temp mail file
  44. ARGN=0            # argument counter
  45.  
  46. while [ $# -gt 0 ]    # Check out args...
  47. do
  48.     case $1 in
  49.     -help)        print ""
  50.             print "sendproc accepts:"
  51.             print "    -noxface"
  52.             print "    -xface facefile"
  53.             print "    -nofcc"
  54.             print "    -fcc fccfile"
  55.             print "    -(nosig)nature"
  56.             print "    -(sig)nature sigfile"
  57.             print ""
  58.             print "Defaults:"
  59.             print "    -xface $HOME/.face -fcc outbox"
  60.             print ""
  61.             print "The default for the .signature depends on 'friends'. See the sendproc script."
  62.             print ""
  63.             print "sendproc also accepts 'send' arguments:"
  64.             print ""
  65.  
  66.             $SEND -help
  67.  
  68.             exit 1            ;;
  69.     -noxface)    XFACE=0            ;;
  70.     -xface)        if [ -f "$2" ]
  71.             then
  72.                 shift
  73.                 XFACEFN=$1
  74.             else
  75.                 print sendproc: "$2" is not a valid file
  76.                 exit 1
  77.             fi            ;;
  78.     -nosig*)    SIG=0            ;;
  79.     -sig*)        SIG=2
  80.  
  81.             if [ -f "$2" ]
  82.             then
  83.                 shift
  84.                 SIGFN=$1
  85.             else
  86.                 print sendproc: "$2" is not a valid file
  87.                 exit 1
  88.             fi            ;;
  89.     -nofcc)        FCC=0            ;;
  90.     -fcc)        if [ -f "$2" ]
  91.             then
  92.                 shift
  93.                 FCCFN=$1
  94.             else
  95.                 print sendproc: "$2" is not a valid file
  96.                 exit 1
  97.             fi            ;;
  98.  
  99.     # Just record all args we don't know about and pass them to
  100.     # the send program
  101.  
  102.     *)        args[$ARGN]=$1
  103.             let ARGN=$ARGN+1    ;;
  104.     esac
  105.  
  106.     shift    # next arg
  107. done
  108.  
  109. DRAFT=${args[$ARGN-1]}    # ASSUMPTION: last arg is the draft file
  110.  
  111. cat $DRAFT | (        # Build draft file extensions
  112.  
  113. # Face stuff...
  114.  
  115. if [ $XFACE -eq 1 ]        # X-Face: stuff
  116. then
  117.     if [ -f "$XFACEFN" ]
  118.     then
  119.         print -n X-Face:
  120.         cat $XFACEFN
  121.     fi
  122. fi
  123.  
  124. if [ $FCC -eq 1 ]        # Fcc: stuff
  125. then
  126.     print "Fcc: $FCCFN"
  127. fi
  128.  
  129. IFS_ORIG=$IFS
  130.  
  131. IFS=
  132. SIGFLAG=1            # Default sig is 'internal'
  133.  
  134. # CONFIGURE: You probably want to change this list...
  135.  
  136. while read line
  137. do
  138.     echo "$line"
  139.     case $line in
  140.     "") break             ;; # Blank line after the subject...
  141.     To:*march*)      SIGFLAG="0"    ;; # friends...
  142.     To:*marty*)      SIGFLAG="0"    ;; # friends...
  143.     To:*leggiero*)   SIGFLAG="0"    ;; # friends...
  144.     To:*jason*)      SIGFLAG="0"    ;; # friends...
  145.     To:*mary*)       SIGFLAG="0"    ;; # friends...
  146.     To:*rrad*)       SIGFLAG="0"    ;; # friends...
  147.     To:*sheppard*)   SIGFLAG="0"    ;; # friends...
  148.     To:*balick*)     SIGFLAG="0"    ;; # friends...
  149.     To:*zhigang*)    SIGFLAG="0"    ;; # friends...
  150.     To:*atul*)       SIGFLAG="0"    ;; # friends...
  151.     To:*wittner*)    SIGFLAG="0"    ;; # friends...
  152.     To:*gen*)        SIGFLAG="0"    ;; # friends...
  153.     To:*clare*)      SIGFLAG="0"    ;; # friends...
  154.     To:*amyliv*)     SIGFLAG="0"    ;; # friends...
  155.     To:*sanders*)    SIGFLAG="0"    ;; # friends...
  156.     To:*laxmi*)      SIGFLAG="0"    ;; # friends...
  157.     To:*rsmith*)     SIGFLAG="0"    ;; # friends...
  158.     To:*aispeech*)   SIGFLAG="0"    ;; # friends...
  159.     To:*jrs*)        SIGFLAG="0"    ;; # friends...
  160.     To:*sara*)       SIGFLAG="0"    ;; # friends...
  161.     To:*dina*)       SIGFLAG="0"    ;; # friends...
  162.     To:*ben*)        SIGFLAG="0"    ;; # friends...
  163.     To:*dav*)        SIGFLAG="0"    ;; # friends...
  164.     To:*kimsilv*)    SIGFLAG="0"    ;; # friends...
  165.     To:*lisar*)      SIGFLAG="0"    ;; # friends...
  166.     To:*jules*)      SIGFLAG="0"    ;; # friends...
  167.     To:*ken*)        SIGFLAG="0"    ;; # friends...
  168.     To:*ashokk*)     SIGFLAG="0"    ;; # friends...
  169.     To:*pitrelli*)   SIGFLAG="0"    ;; # friends...
  170.     To:*smehta*)     SIGFLAG="0"    ;; # friends...
  171.     To:*srs*)        SIGFLAG="0"    ;; # friends...
  172.     To:*asadi*)      SIGFLAG="0"    ;; # friends...
  173.     To:*hcl*)        SIGFLAG="0"    ;; # friends...
  174.     To:*nancyk*)     SIGFLAG="0"    ;; # friends...
  175.     To:*em*)         SIGFLAG="0"    ;; # friends...
  176.     To:*weather*)    SIGFLAG="1"    ;; # internal weather mailing list
  177.     To:*c++*)        SIGFLAG="1"    ;; # internal c++ mailing list
  178.     To:*nasanews*)   SIGFLAG="1"    ;; # internal nasanews mailing list
  179.     To:*recog*)      SIGFLAG="0"    ;; # internal speech recog mailing list
  180.     To:*tam*)        SIGFLAG="0"    ;; # internal "Talk About Money" list
  181.     To:*synth*)      SIGFLAG="0"    ;; # internal speech synth mailing list
  182.     To:*@* | To:*!*) SIGFLAG="2"    ;; # External mail?
  183.     esac
  184. done
  185.  
  186. IFS=$IFS_ORIG
  187.  
  188. cat    # the message
  189.  
  190. case $SIG in
  191.     0)    break                    ;;
  192.     1)    case $SIGFLAG in
  193.             "0") break                ;;
  194.             "1") cat $INTERNAL            ;;
  195.             "2") cat $EXTERNAL            ;;
  196.         esac                    ;;
  197.     2)    cat $SIGFN                ;;
  198. esac
  199.  
  200. ) > $TMPFILE
  201.  
  202. # Could I do this with a -nodraft option to send?
  203.  
  204. rm -f $DRAFT
  205. mv $TMPFILE $DRAFT
  206.  
  207. $SEND ${args[*]}    # send new draft
  208.